﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CDIO.Models;
using ADL;

namespace CDIO.Controllers
{
    public class GiftController : Controller
    {
        //
        // GET: /Home/
        public GiftModel giftModel = null;

        public ActionResult Gift_Search(string username)
        {
            ViewBag.Message = username;

            ADL_gift ad_us = new ADL_gift();
            _gift us = new _gift();
            List<_gift> listuse = ad_us.search(null, "*");
            if (listuse != null)
            {
                giftModel = new GiftModel
                {
                    account = "" + listuse.Count,
                    UserModel_gift = listuse
                };
            }

            return View(giftModel);
        }

        public ActionResult Gift_Add(string username)
        {
            ViewBag.Message = username;
            return View();
        }

        public ActionResult Gift_Detail(string username, string _gift_id)
        {
            ViewBag.Message = username;

            ADL_gift ad_us = new ADL_gift();
            _gift us = new _gift();
            us._gift_id = _gift_id;
            List<_gift> listuse = ad_us.search(us, "_user_id");
            if (listuse != null)
            {
                giftModel = new GiftModel
                {
                    _gift_id = listuse[0]._gift_id,
                    _gift_type = listuse[0]._gift_type,
                    _gift_name = listuse[0]._gift_name,
                    _gift_credit = listuse[0]._gift_credit,
                    _gift_src = listuse[0]._gift_src,
                    _gift_account = listuse[0]._gift_account,
                    _gift_state = listuse[0]._gift_state,
                    _gift_rangetime = listuse[0]._gift_rangetime,
                    _gift_sorttime = listuse[0]._gift_sorttime,
                    _gift_descript = listuse[0]._gift_descript
                };
            }

            return View(giftModel);
        }


    }
}
